<?php
require("bases.php");

class cato extends bases {

    public function __construct(){
        parent::__construct();
        try{

        }catch(Exception $e){

        }
    }


    public function catolist(){
        try{
            $redata = array();
            $postdata = $this->spArgs();
            $obj_cato_course = spClass("cato_course");

            $condition = "isdel=0 and status=1 and parent_id=0 and level_id=1 ";
            $redata['cato_rs'] = $obj_cato_course->findAll($condition, 'sort asc, id desc');
            /*
            $page = intval(max($postdata['page'], 1));
            $number = 20;
            $start = ($page-1) * $number;
            $searchnumber = $number + 1;

            $redata["cato_count"] = $obj_cato_course->findCount($condition);
            import("Common.php");
            $redata["cato_rs"] = Common::PageList($redata["cato_rs"],$searchnumber,$page);
            */
            $this->returnApi($redata);
        }catch(Exception $e){
            echo json_encode(array("data"=>array(), "message"=>$e->getMessage(), "code"=>400));
            exit();
        }
    }

    public function getAllCourse(){
        $redata = array();
        $postdata = $this->spArgs();
        $obj_cato_course = spClass("cato_course");


        $condition = "isdel=0 and status=1 and parent_id=". intval($postdata['cataid']) ." and level_id=2";
        $redata['cato_rs'] = $obj_cato_course->findAll($condition, 'sort asc, id desc');
        /*
        $page = intval(max($postdata['page'], 1));
        $number = 20;
        $start = ($page-1) * $number;
        $searchnumber = $number + 1;
        $redata["cato_count"] = $obj_cato_course->findCount($condition);
        import("Common.php");
        $redata["cato_rs"] = Common::PageList($redata["cato_rs"],$searchnumber,$page);
        */
        $this->returnApi($redata);
    }

    public function getAllExper(){
        $redata = array();
        $postdata = $this->spArgs();
        $obj_cato_course = spClass("cato_course");


        $condition = "isdel=0 and status=1 and parent_id=". intval($postdata['courseid']) ." and parent_id1 = ".intval($postdata['cataid'])." and level_id=3";
        $redata['cato_rs'] = $obj_cato_course->findAll($condition, 'sort asc, id desc');
        /*
        $page = intval(max($postdata['page'], 1));
        $number = 20;
        $start = ($page-1) * $number;
        $searchnumber = $number + 1;
        $redata["cato_count"] = $obj_cato_course->findCount($condition);
        import("Common.php");
        $redata["cato_rs"] = Common::PageList($redata["cato_rs"],$searchnumber,$page);
        */
        $this->returnApi($redata);
    }
}
